<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=${encoding}">
<meta http-equiv="Content-Style-Type" content="text/css">
<title>Welcome to JForum ${version} Installation</title>
<link rel="stylesheet" href="${contextPath}/templates/default/styles/style.css" type="text/css">
<style type="text/css">
th			{ background-image: url('${contextPath}/templates/default/images/cellpic3.gif') }
td.cat		{ background-image: url('${contextPath}/templates/default/images/cellpic1.gif') }
td.rowpic	{ background-image: url('${contextPath}/templates/default/images/cellpic2.jpg'); background-repeat: repeat-y }
td.cathead,td.catsides,td.catleft,td.catright,td.catbottom { background-image: url('${contextPath}/templates/default/images/cellpic1.gif') }
</style>

<script language="javascript">
function validateForm()
{
	var status = checkDatabase();
	status = status && checkBoard();
	return status;
}

function checkBoard()
{
	var f = document.install;
	var s = "";

	if (f.forum_link.value == "") {
		s += "${I18n.getMessage("Install.domainName")} ${I18n.getMessage("Install.isEmpty")}\n";
	}

	if (f.admin_pass1.value == "") {
		s += "${I18n.getMessage("Administrator")} ${I18n.getMessage("User.password")} ${I18n.getMessage("Install.isEmpty")}\n";
	}

	if (f.admin_pass1.value != f.admin_pass2.value) {
		s += "${I18n.getMessage("Administrator")} ${I18n.getMessage("User.password")} ${I18n.getMessage("Install.confirmationNotMatch")}\n";
	}

	if (s != "") {
		alert("${I18n.getMessage("Install.issuesFound")}: \n\n" + s + "\n${I18n.getMessage("Install.pleaseCorrect")}");
		return false;
	}

	return true;
}

function checkDatabase()
{
	var f = document.install;
	var s = "";
  
	if (f.db_connection_type.selectedIndex == 0) {  // native selected
		if (f.dbpasswd.value != f.dbpasswd_confirm.value) {
			alert("${I18n.getMessage("Install.dbPasswdNotMatch")}");
			return false;
		}    
		
		if (f.database.value != "hsqldb") {
			if (f.dbuser.value == "") {
				s += "${I18n.getMessage("Install.dbUsername")} ${I18n.getMessage("Install.isEmpty")}\n";
			}
    
			if (f.dbpasswd.value == "") {
				s += "${I18n.getMessage("Install.dbPassword")} ${I18n.getMessage("Install.isEmpty")}\n";
			}

			if (f.dbport.value == "") {
				s += "${I18n.getMessage("Install.dbPort")} ${I18n.getMessage("Install.isEmpty")}\n";
			}
		}
		else {
			if (f.dbpasswd.value == "" || f.dbuser.value == "") {
				if (confirm("${I18n.getMessage("Install.hsqldbDefault")}. \n${I18n.getMessage("Install.jforumUseDefault")}")) {
					return true;
				}
    
				return false;
			}
		}
	} 
	else {
		if (f.dbdatasource.value == "") {
			s += "${I18n.getMessage("Install.dbDataSource")} ${I18n.getMessage("Install.isEmpty")}\n";
		}
	}
	
	if (s != "") {
		if (confirm("${I18n.getMessage("Install.dbIssues")}: \n\n" + s + "\n${I18n.getMessage("Install.dbMayResultError")}")) {
			return true;
		}
		
		return false;
	}

	return true;
}

function changeDbPort(dbName)
{
	var port = document.install.dbport;

	if (dbName == "mysql") port.value = 3306;
	else if (dbName == "oracle") port.value = 1521;
	else if (dbName == "postgresql") port.value = 5432;
	else if (dbName == "sqlserver2000") port.value = 1433;
	else if (dbName == "hsqldb") { 
		port.value = "";
		port.enabled = false;
	}
}
</script>
</head>
<body text="#000000" link="#006699" vlink="#5584AA">

<table width="70%" height="100%" align="center">
<tr>
<td valign="middle" align="center">

<table width="100%" border="0" cellspacing="0" cellpadding="10" align="center"> 
	<tr>
		<td class="bodyline" width="100%"><table width="100%" border="0" cellspacing="0" cellpadding="0">

			<tr>
				<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
					<tr>
						<td><img src="${contextPath}/templates/default/images/logo.jpg" border="0" alt="JForum" vspace="1" /></td>
						<td align="center" width="100%" valign="middle"><span class="maintitle">${I18n.getMessage("Install.welcome")} JForum ${version} ${I18n.getMessage("Install.installation")}</span></td>
					</tr>
				</table></td>
			</tr>

			<tr>
				<td align="center"><br /><br /></td>
			</tr>
			<tr>
				<td colspan="2"><table width="90%" border="0" align="center" cellspacing="0" cellpadding="0">
					<tr>
						<td>
							<span class="gen">
							${I18n.getMessage("Install.welcomeMessage")}
							<br/></br>
							${I18n.getMessage("Install.forHelpAccess")} <a href="http://www.jforum.net/install.htm">http://www.jforum.net/install.htm</a>
							<p align="center">${I18n.getMessage("Install.notPerfect")}</p>
							</span>
						</td>
					</tr>

				</table></td>
			</tr>
			<tr>
				<td align="center" valign="middle"><br/><span class="maintitle">${I18n.getMessage("Install.step1")}</span></td>
			</tr>
			<tr>
				<td width="100%"><table width="100%" cellpadding="2" cellspacing="1" border="0" class="forumline">
				<form action="${JForumContext.encodeURL("/install/install")}" name="install" method="post" onSubmit="return validateForm();">
				<input type="hidden" name="module" value="install">
				<input type="hidden" name="action" value="checkInformation">
					<tr>
						<th colspan="2">1) ${I18n.getMessage("Install.general")}</th>

					</tr>
					<tr>
						<td class="row3" align="right" width="40%"><span class="gen"><b>${I18n.getMessage("Install.boardLanguage")}:</b> </span></td>
						<td class="row3">
							<select name="language" onChange="document.location = '${contextPath}/install/install${extension}?module=install&action=welcome&l=' + this.value;">
								<option value="en_US" <#if language?default("") == "en_US">selected</#if>>English American (en_US)</option>
								<option value="zh_TW" <#if language?default("") == "zh_TW">selected</#if>>Chinese Traditional (zh_TW)</option>
								<option value="zh_CN" <#if language?default("") == "zh_CN">selected</#if>>Chinese Simplifed (zh_CN)</option>
								<!--<option value="fr_FR" <#if language?default("") == "fr_FR">selected</#if>>French (fr_FR)</option>-->
								<option value="de_DE" <#if language?default("") == "de_DE">selected</#if>>German (de_DE)</option>
								<!--<option value="nl_NL" <#if language?default("") == "nl_NL">selected</#if>>Dutch (nl_NL)</option>-->
								<option value="pt_BR" <#if language?default("") == "pt_BR">selected</#if>>Portugu&ecirc;s do Brasil (pt_BR)</option>
								<option value="pt_PT" <#if language?default("") == "pt_PT">selected</#if>>Portuguese (Portugal) (pt_PT)</option>
								<!--<option value="ru_RU" <#if language?default("") == "ru_RU">selected</#if>>Russian (ru_RU)</option>-->
								<!--<option value="ar_SA" <#if language?default("") == "ar_SA">selected</#if>>Arabic (Saudi Arabia) (ar_SA)</option>-->
								<!--<option value="fi_FI" <#if language?default("") == "fi_FI">selected</#if>>Finnish (Finland) (fi_FI)</option>-->
								<option value="hu_HU" <#if language?default("") == "hu_HU">selected</#if>>Hungarian (Hungary) (hu_HU)</option>
								<option value="it_IT" <#if language?default("") == "it_IT">selected</#if>>Italian (Italy) (it_IT)</option>
								<!--<option value="pl_PL" <#if language?default("") == "pl_PL">selected</#if>>Polish (Poland) (pl_PL)</option>-->
								<!--<option value="sp_SP" <#if language?default("") == "sp_SP">selected</#if>>Spanish (sp_SP)</option>-->
								<!--<option value="es_ES" <#if language?default("") == "es_ES">selected</#if>>Spanish (Spain) (es_ES)</option>-->
								<!--<option value="sv_SV" <#if language?default("") == "sv_SV">selected</#if>>Swedish (sv_SV)</option>-->
								<!--<option value="vi_VN" <#if language?default("") == "vi_VN">selected</#if>>Vietnamese (Vietnam) (vi_VN)</option>-->
								<option value="nb_NO" <#if language?default("") == "nb_NO">selected</#if>>Norwegian (Norway) (nb_NO)</option>
							</select>
						</td>
					</tr>
					<tr>
						<td class="row1" align="right" valign="top"><span class="gen"><b>${I18n.getMessage("Install.dbType")}: </b></span></td>
						<td class="row1">
							<select name="database" onChange="changeDbPort(this.value);">
								<option value="mysql" <#if database?default("") == "mysql">selected</#if>>MySQL</option>
								<option value="postgresql" <#if database?default("") == "postgresql">selected</#if>>PostgreSQL</option>
								<option value="oracle" <#if database?default("") == "oracle">selected</#if>>Oracle</option>
								<option value="hsqldb" <#if database?default("") == "hsqldb">selected</#if>>HSQLDB</option>
								<option value="sqlserver2000" <#if database?default("") == "sqlserver2000">selected</#if>>SQL Server 2000</option>
							</select>
							<br>
							<span class="gensmall">
							<font color="green">${I18n.getMessage("Install.dbTip")}</font>
						</td>
					</tr>

					<tr>
						<td class="row3" align="right" valign="top"><span class="gen"><b>${I18n.getMessage("Install.type")}:</b></span></td>
						<td class="row3">
							<select name="install_type">
								<option value="0">${I18n.getMessage("Install.typeNew")}</option>
							</select>
							<br/><span class="gensmall"><font color="green">${I18n.getMessage("Install.upgradeNotSupported")}</font></span>
						</td>

					</tr>
					<tr>
						<th colspan="2">2) ${I18n.getMessage("Install.dbConfiguration")}</th>
					</tr>
					<tr>
						<td class="row1" colspan="2">
						<span class="gensmall">
						${I18n.getMessage("Install.dbTipGeneral")}
						</span>
						</td>
					</tr>

					<script language="javascript">
					function enableNativeFields()
					{
						var f = document.forms[0];
						var status = (f.db_connection_type.selectedIndex == 0);
						var color = "#ffffff";
						
						if (!status) {
							color = "#cccccc";						
						}

						f.dbdatasource.style.bgcolor = !status ? "#ffffff" : color;
						f.dbdatasource.disabled = status;

						f.dbhost.style.bgcolor = color;
						f.dbhost.disabled = !status;

						f.dbname.style.bgcolor = color;
						f.dbname.disabled = !status;

						f.dbport.style.bgcolor = color;
						f.dbport.disabled = !status;

						f.dbuser.style.bgcolor = color;
						f.dbuser.disabled = !status;

						f.dbpasswd.style.bgcolor = color;
						f.dbpasswd.disabled = !status;

						f.dbpasswd_confirm.style.bgcolor = color;
						f.dbpasswd_confirm.disabled = !status;

						f.dbencoding.style.bgcolor = color;
						f.dbencoding.disabled = !status;

						f.dbencoding_other.style.bgcolor = color;
						f.dbencoding_other.disabled = !status;

						f.use_pool.style.bgcolor = color;
						f.use_pool.disabled = !status;
					}
					</script>

					<tr>
						<td class="row3" align="right" valign="top"><span class="gen"><b>${I18n.getMessage("Install.dbConnectionType")}</b></span></td>
						<td class="row3">
							<select name="db_connection_type" onChange="enableNativeFields()">
								<option value="JDBC" <#if db_connection_type?default("native") == "native">selected</#if>>${I18n.getMessage("Install.dbConnectionTypeNative")}</option>
								<option value="ds" <#if db_connection_type?default("native") == "ds">selected</#if>>${I18n.getMessage("Install.dbConnectionTypeDs")}</option>
							</select><br/>
							<span class="gensmall"><font color="green">${I18n.getMessage("Install.dbConnectionTypeTip")}</font></span>
						</td>
					</tr>

					<tr>
						<td class="row1" align="right" valign="top"><span class="gen"><b>${I18n.getMessage("Install.dbDataSource")}</b></span></td>
						<td class="row1">
							<input type="text" name="dbdatasource" value="${dbdatasource?default("")}" disabled style="bgcolor: #cccccc;"/><br/>
							<span class="gensmall"><font color="green">${I18n.getMessage("Install.dbDataSourceTip")}</font></span>
						</td>
					</tr>

					<tr>
						<td class="row3" align="right"><span class="gen"><b>${I18n.getMessage("Install.dbHost")}</b></span></td>
						<td class="row3"><input type="text" name="dbhost" value="${dbhost?default("localhost")}" /></td>
					</tr>

					<tr>
						<td class="row1" align="right" valign="top"><span class="gen"><b>${I18n.getMessage("Install.dbPort")}</b></span></td>
						<td class="row1">
							<input type="text" name="dbport" value="<#if !database?exists>3306<#else>${dbport?default("")}</#if>" /><br>
							<span class="gensmall"><font color="green">${I18n.getMessage("Install.dbPortTip")}</font></span>
						</td>
					</tr>

					<tr>
						<td class="row3" align="right" valign="top"><span class="gen"><b>${I18n.getMessage("Install.dbName")}: </b></span></td>
						<td class="row3">
						<input type="text" name="dbname" value="${dbname?default("jforum")}" /><br/>
						<span class="gensmall"><font color="green">${I18n.getMessage("Install.dbNameTip")}</font></span>
						</td>
					</tr>
					<tr>
						<td class="row1" align="right"><span class="gen"><b>${I18n.getMessage("Install.dbUsername")}: </b></span></td>
						<td class="row1"><input type="text" name="dbuser" value="${dbuser?default("")}" /></td>
					</tr>

					<tr>
						<td class="row3" align="right"><span class="gen"><b>${I18n.getMessage("Install.dbPassword")}: </b></span></td>
						<td class="row3"><input type="password" name="dbpasswd" value="${dbpasswd?default("")}" /></td>
					</tr>

					<tr>
						<td class="row1" align="right"><span class="gen"><b>${I18n.getMessage("Install.dbPassword")} [ ${I18n.getMessage("Install.confirm")} ]: </b></span></td>
						<td class="row1"><input type="password" name="dbpasswd_confirm" value="" /></td>
					</tr>

					<tr>
						<td class="row3" align="right" valign="top"><span class="gen"><b>${I18n.getMessage("Install.dbEncoding")}: </b></span></td>
						<td class="row3">
							<select name="dbencoding">
								<option value="">${I18n.getMessage("Install.selectEncodig")}</option>
								<option value="utf-8" <#if dbencoding?default("") == "utf-8">selected</#if>>UTF-8</option>
								<option value="iso-8859-1" <#if dbencoding?default("") == "iso-8859-1">selected</#if>>ISO-8859-1</option>
							</select>
							&nbsp;
							<span class="gen"><b>${I18n.getMessage("Install.other")} </b></span><input type="text" name="dbencoding_other" value="${dbencoding?default("")}">
							<br/>
							<span class="gensmall">
							<font color="green">${I18n.getMessage("Install.encodingTip")}</font>
							</span>
						</td>
					</tr>

					<tr>
						<td class="row1" align="right"><span class="gen"><b>${I18n.getMessage("Install.pool")}: </b></span></td>
						<td class="row1">
							<select name="use_pool">
								<option value="yes" <#if use_pool?default("") == "yes">selected</#if>>${I18n.getMessage("User.yes")}</option>
								<option value="no" <#if use_pool?default("") == "no">selected</#if>>${I18n.getMessage("User.no")}</option>
							</select>
						</td>
					</tr>

					<tr>
						<th colspan="2">3) ${I18n.getMessage("Install.boardConfiguration")}</th>
					</tr>
					<tr>
						<td class="row3" align="right"><span class="gen"><b>${I18n.getMessage("Install.forumLink")}: </b></span></td>
						<#if serverPort != "80"><#assign serverName = serverName + ":" + serverPort/></#if>
						<#assign flink = serverName + contextPath?default("") + "/"/>
						<td class="row3"><input type="text" name="forum_link" value="${forumLink?default("http://${flink}")}" size="40"/></td>
					</tr> 
					<tr>
						<td class="row1" align="right"><span class="gen"><b>${I18n.getMessage("Install.siteLink")}: </b></span></td>
						<td class="row1"><input type="text" name="site_link" value="${siteLink?default("http://${serverName}")}" size="40"/></td>
					</tr> 
					<tr>
						<td class="row3" align="right"><span class="gen"><b>${I18n.getMessage("Install.adminUser")}: </b></span></td>
						<td class="row3"><span class="gen">Admin</span></td>
					</tr>
					<tr>

						<td class="row1" align="right"><span class="gen"><b>${I18n.getMessage("Install.adminPassword")}: </b></span></td>
						<td class="row1"><input type="password" name="admin_pass1" value="" /></td>
					</tr>
					<tr>
						<td class="row3" align="right"><span class="gen"><b>${I18n.getMessage("Install.adminPassword")} [ ${I18n.getMessage("Install.confirm")} ]: </b></span></td>
						<td class="row3"><input type="password" name="admin_pass2" value="" /></td>
					</tr>
					<tr> 
					  <td class="catbottom" align="center" colspan="2">
						<input type="hidden" name="install_step" value="1" />
						<input class="mainoption" type="submit" value="${I18n.getMessage("Install.nextStep")}" />
					</td>
					</tr>
				</table>
			</form>
		</td>
	</tr>
</table></td>
	</tr>
</table>

</td>
</tr>
</table>

</body>
</html>
